package xin.xihc.jba.sql.clause;

import xin.xihc.jba.sql.KV;

/**
 * 等于 条件 用于Set/Where语句，实现增加/减少version=version+1类似的
 *
 * @author Leo.Xi
 * @date 2020/3/5
 * @since 1.0
 **/
public class EqSelf extends Eq {

    private boolean added = true;

    public EqSelf(String columnName, Object value) {
        super(columnName, value);
    }

    public EqSelf(String columnName, Object value, boolean added) {
        super(columnName, value);
        this.added = added;
    }

    @Override
    public String toSql(KV kv) {
        String key = ":" + kv.add(this.value());
        return this.columnName + this.operation() + this.columnName + (this.added ? " + " : " - ") + key;
    }
}
